﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.Mvc;

namespace MvcImproved.Generic.Controls
{
	public class TypedContainer<T> : System.Web.UI.Control, INamingContainer, IViewDataContainer<T>
	{
		protected T _DataItem;

		public T DataItem
		{
			get
			{
				return _DataItem;
			}
		}

		public TypedContainer(T dataItem)
		{
			_DataItem = dataItem;
			ViewData = new ViewDataDictionary<T>(dataItem);
		}

		public ViewDataDictionary<T> ViewData
		{
			get;
			set;
		}

		ViewDataDictionary IViewDataContainer.ViewData
		{
			get
			{
				return ViewData;
			}
			set
			{
				ViewData = (ViewDataDictionary<T>)value;
			}
		}
	}
}